package com.m.exception;

/**
 * 功能: <br/>
 *
 * @author miracle
 */
public class BaseException extends RuntimeException implements IExceptionInfo {

    private static final long serialVersionUID = 1L;

    public BaseException(String message, Throwable cause) {
        super(message, cause);
    }

    public BaseException() {
    }

    public BaseException(String msg) {
        super(msg);
    }

    public BaseException(Throwable cause) {
        super(cause);
    }

    @Override
    public int getCode() {
        int code = getExceptionCode();
        if (code == -1) {
            return ExceptionCodeEnum.BASEEXCEPTION.getExceptionCode();
        } else {
            return code;
        }
    }

    public enum ExceptionCodeEnum {
        ERROR(-1),
        BASEEXCEPTION(100000),
        ACMEXCEPTION(100001),
        BDOPSEXCEPTION(100002),
        CLUSTEROPEREXCEPTION(100003),
        PARAMEXCEPTION(100004),
        DOMAINOPEREXCEPTION(100005),
        FTPEXCEPTION(100006);

        ExceptionCodeEnum(int exceptionCode) {
            this.exceptionCode = exceptionCode;
        }

        private int exceptionCode;

        public int getExceptionCode() {
            return exceptionCode;
        }
    }
}